package epam.bookShelf.actors;

import epam.bookShelf.stuff.Library;

/**
 * DTO for Reader
 * Editable fields:
 * login
 * pass
 * realName
 * privacy
 * @author Pustovit Michael, pustovitm@gmail.com
 */
public class Reader {
	public static String AUTH_SESSION_ATTRIBUTE = "auth";
	
	private String login;
	private String pass;
	private String realName;
	private int privacy;
	public Library library;

	public Reader(String login, String pass, String realName, int privacy) {
		this.login 		= login;
		this.pass 		= pass;
		this.realName 	= realName;
		this.privacy 	= privacy;
	}

    public Reader(String login, String pass) {
        this.login 		= login;
        this.pass 		= pass;
        
        this.privacy 	= 0;
    }

    //===========Getters/setters area============
    public void setLogin(String login) {
        this.login = login;
    }

    public String getLogin() {
        return login;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getPass() {
        return pass;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getRealName() {
        return realName;
    }

	public Library getLibrary() {
		return library;
	}

	public void setLibrary(Library library) {
		this.library = library;
	}

	public int getPrivacy() {
		return privacy;
	}

	public void setPrivacy(int privacy) {
		this.privacy = privacy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((library == null) ? 0 : library.hashCode());
		result = prime * result + ((login == null) ? 0 : login.hashCode());
		result = prime * result + ((pass == null) ? 0 : pass.hashCode());
		result = prime * result + privacy;
		result = prime * result
				+ ((realName == null) ? 0 : realName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Reader other = (Reader) obj;
		if (library == null) {
			if (other.library != null)
				return false;
		} else if (!library.equals(other.library))
			return false;
		if (login == null) {
			if (other.login != null)
				return false;
		} else if (!login.equals(other.login))
			return false;
		if (pass == null) {
			if (other.pass != null)
				return false;
		} else if (!pass.equals(other.pass))
			return false;
		if (privacy != other.privacy)
			return false;
		if (realName == null) {
			if (other.realName != null)
				return false;
		} else if (!realName.equals(other.realName))
			return false;
		return true;
	}
}